import axios from "axios";
import http from "@/api/http.js";
const baseUrl = "http://localhost:8091";
const processRequest={
    loadProcess(process,page=1,limit=10,callBack){
        let url = baseUrl + "/process/selectAll?page=" + page + "&limit=" + limit;
        if (process){
            if (process.processId){
                url += "&processId=" + process.processId;
            }
            if (process.processType){
                url += "&processType=" + process.processType;
            }
            if (process.processTicketsId){
                url += "&processTicketsId=" + process.processTicketsId;
            }
            if (process.processItemName){
                url += "&processItemName=" + process.processItemName;
            }
            if (process.processMaterialOutcome){
                url += "&processMaterialOutcome=" + process.processMaterialOutcome;
            }
        }
        axios.get(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
//     新增过程检验信息
    loadAddProcess(process,callBack){
        let url = baseUrl + "/process/add";
        axios.post(url,process,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
//     根据id查询数据信息
    loadSelectByIdProcess(processId,callBack){
        let url = baseUrl + "/process/selectById?processId=" + processId;
        axios.get(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
//     根据id修改数据信息
    loadUpdateProcess(process,callBack){
        let url = baseUrl + "/process/update";
        axios.put(url,process,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
//     根据id删除数据信息
    loadDeleteProcess(processId,callBack){
        let url = baseUrl + "/process/delete?processId=" + processId;
        axios.delete(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    }
}
export default processRequest;